var submitbtn = document.querySelector('.submi');
var succ = document.querySelector('.succ');
var keepwrite = document.querySelector('.keepwrite');
var close = document.querySelectorAll('.close');
var inps = document.querySelectorAll('input[type="text"]');


var hasword = true;
submitbtn.addEventListener('click',function(){
	//有没有没有输入的输入框
	for(var i=0; i<inps.length; i++){
		if (inps[i].value == '') {
			hasword = false;
		}
	}
	//如果第1个input不是名字的话，hasword为false
	//如果第2个input不是电话的话，hasword为false
	
	//根据hasword对错来选择弹出框
	if (hasword) {
		succ.style['display'] = 'block';
	} else{
		keepwrite.style['display'] = 'block';
	}
})
//关闭窗口
close[0].addEventListener('click',function(){
	succ.style['display'] = 'none';
})
close[1].addEventListener('click',function(){
	keepwrite.style['display'] = 'none';
	hasword = true;
	for(var i=inps.length-1; i>=0 ; i--){
		var index = i;
		if (inps[index].value == '') {
			inps[index].focus();
		}
	}
})


//document.addEventListener('click',function(e){
//	if (e.targetgetcl == 'close') {
//		
//	}
//	console.log(1)
//	keepwrite.style['display'] = 'none';
//	succ.style['display'] = 'none';
//})